﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Estimate.Common.Estimate;

namespace EstimateService
{
    public partial class ExecutionStatusReportHandler : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string tid = Request.QueryString["tid"] != null ? Request.QueryString["tid"].ToString() : "";
            string action = Request.QueryString["action"] != null ? Request.QueryString["action"].ToString() : "";

            if (tid == "") return;

            if (action == "delete")
                Response.Write(DeleteExecutionStatus(tid));
            else
                Response.Write(GetExecutionStatus(tid));
        }

        /// <summary>
        /// 获取程序执行状态
        /// </summary>
        /// <param name="tid">任务号</param>
        /// <returns></returns>
      
        public string GetExecutionStatus(string tid)
        {
            ExecutionStatus exeStatus = new ExecutionStatus(tid);
            return exeStatus.GetStatusFromCache(tid);
        }

        /// <summary>
        /// 从缓存中删除程序执行状态
        /// </summary>
        /// <param name="tid">任务号</param>
        /// <returns></returns>
      
        public bool DeleteExecutionStatus(string tid)
        {
            ExecutionStatus exeStatus = new ExecutionStatus(tid);
            return exeStatus.DeleteStatusFromCache(tid);
        }

    }
}